import React, { useState, useEffect } from 'react';
import { Tabs ,Form, Button,Space,Table, Input, InputNumber, Popconfirm, Typography,Modal,Radio } from 'antd';

import { UserOutlined, LockOutlined,PlusOutlined } from '@ant-design/icons';

import {getAuthList} from '../../api/auth'
import './index.css'
const { TabPane } = Tabs;




export default function Index(props){


  console.log("权限列表获取到的props",props);

  const [form] = Form.useForm();
  const [, forceUpdate] = useState({}); // To disable submit button at the beginning.
  const [tableobj,setTableobj]=useState([]);
  useEffect(() => {
      //设置表格所需要的属性
  getAuthList().then((data)=>{

    setTableobj(data.data);

  })
    
    
  }, []);

  useEffect(() => {
    forceUpdate({});
  }, []);

  const onFinish = (values) => {
    console.log('Finish:', values);
    //
    props.dispatch({type:"QXsearch",obj:values})
  };
  const onReset=()=>{
    //设置仓库search={}
    props.dispatch({type:"QXsearch",obj:{}});
    form.resetFields();
  }

  function addList(){
    //点击新建按钮弹出模态框 changeSwitch
    props.dispatch({type:"changeSwitch",name:true});
  }
  return(
    <>
    
    <div className="headquery">
  
    <Form form={form} name="查询列表" layout="inline" onFinish={onFinish} >

    <Space size={32}>
       <Form.Item
        name="id"
        label="ID"
        rules={[
          {
            required: true,
            message: 'Please input your username!',
          },
        ]}
      >
        <Input placeholder="请输入ID" />
      </Form.Item>

      <Form.Item
        name="name"
        label="名称"
        rules={[
          {
            required: true,
            message: 'Please input your password!',
          },
        ]}
      >
        <Input
          placeholder="请输入名称"
        />
      </Form.Item>

       </Space>
    
      <Space size={100}>
  
        <Form.Item>
          </Form.Item>
      <Form.Item >
        <Button type="primary" htmlType="submit">
          查询
        </Button>
        <Button htmlType="button" onClick={onReset}>
          重置
        </Button>
        </Form.Item>

      </Space>
    </Form>
    <div>
      <Button className="addBtn" type="primary" icon={<PlusOutlined /> } onClick={addList} >新建</Button>
    </div>
    </div>
    <div>
      </div>
  
    </>
  )
}



